//
//  ZTNotifiction.m
//  ZHYYTool
//
//  Created by MT-SW-005 on 2021/11/4.
//  Copyright © 2021 MT-SW-005. All rights reserved.
//

#import "ZTNotifiction.h"

@implementation ZTNotifiction

/*
 - (void)addObserver:(id)observer selector:(SEL)aSelector name:(nullable NSNotificationName)aName object:(nullable id)anObject;

 - (void)postNotification:(NSNotification *)notification;
 - (void)postNotificationName:(NSNotificationName)aName object:(nullable id)anObject;
 - (void)postNotificationName:(NSNotificationName)aName object:(nullable id)anObject userInfo:(nullable NSDictionary *)aUserInfo;

 - (void)removeObserver:(id)observer;
 - (void)removeObserver:(id)observer name:(nullable NSNotificationName)aName object:(nullable id)anObject;

 - (id <NSObject>)addObserverForName:(nullable NSNotificationName)name object:(nullable id)obj queue:(nullable NSOperationQueue *)queue usingBlock:(void (^)(NSNotification *note))block API_AVAILABLE(macos(10.6), ios(4.0), watchos(2.0), tvos(9.0));
     // The return value is retained by the system, and should be held onto by the caller in
     // order to remove the observer with removeObserver: later, to stop observation.
*/


-(id)init
{
    self = [super init];
    if (self) {
        center = [NSNotificationCenter defaultCenter];
    }
    return self;
}

/*
 the observer selector function exmple:
 -(void)funcNme:(NSNotification*)noti
 {
  NSString *message = [noti.userInfo objectForKey:@"key"];
 }
 */
- (void)addObserver:(id)observer selector:(SEL)aSelector name:(nullable NSNotificationName)aName object:(nullable id)anObject
{
    [center addObserver:observer selector:aSelector name:aName object:anObject];
}


-(void)sendNotifictionWithName:(nullable NSNotificationName)aName object:(nullable id)anObject userInfo:(nullable NSDictionary *)info
{
    NSNotification *notification = [NSNotification notificationWithName:aName object:anObject userInfo:info];
    [center postNotification:notification];
}


- (void)removeObserver:(id)observer name:(nullable NSNotificationName)aName object:(nullable id)anObject
{
    [center removeObserver:observer name:aName object:anObject];
}
@end
